using rpc_service.cache;
using rpc_service.config;

namespace rpc_service.core.registry;

public class ConsulRegistryFactory : AbstractRegistryFactory
{
    public override Registry CreateRegistry(Config config)
    {
        if (!Supports(config.Registry))
        {
            return null;
        }
        
        return ConsulRegistry.GetInstance(config);
    }

    public override Type GetRegistryType(Config config)
    {
        return "ConsulRegistry".GetTypeByStr();
    }
    
    public override bool Supports(string registryType)
    {
        return !IsNullOrEmpty(registryType) && registryType.ToLower() == "consul";
    }
}